﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ueEngine.Biz.Inf.Entities.DBSupport;
using System.ComponentModel.DataAnnotations;

namespace ueEngine.Biz.Inf.Entities
{
    [Table("ApplicationForm")]
    public class ApplicationForm : BaseEntity<ApplicationForm>
    {
        [Column("Id", TypeName = "int")]
        [Key]
        [DatabaseGenerated(DatabaseGeneratedOption.Identity)]
        public int Id { get; set; }

        [Column(TypeName="nvarchar")]
        [StringLength(64)]
        public string Name { get; set; }

        [Column(TypeName="bit")]
        public bool Gender { get; set; }

        public int Age { get; set; }

        [Column(TypeName = "nvarchar")]
        [StringLength(128)]
        public string IdNo { get; set; }

        [Column(TypeName = "nvarchar")]
        [StringLength(256)]
        public string Job { get; set; }

        [Column(TypeName="nvarchar")]
        [StringLength(256)]
        public string Phone { get; set; }

        [Column(TypeName = "nvarchar")]
        [StringLength(2000)]
        public string Remark { get; set; }

        public override ApplicationForm Get(System.Linq.Expressions.Expression<Func<ApplicationForm, bool>> where)
        {
            using (Context ctx = new Context())
            {
                var item = ctx.ApplicationForm.FirstOrDefault(where);
                if (item != null)
                {
                    this.Id = item.Id;
                    this.Gender = item.Gender;
                    this.Age = item.Age;
                    this.IdNo = item.IdNo;
                    this.Job = item.Job;
                    this.Name = item.Name;
                    this.Remark = item.Remark;
                    this.Phone = item.Phone;
                    return this;
                }
                return null;
            }
        }
    }
}
